package com.imooc.servlet.session;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


@WebServlet("/session/login")
public class SessionLoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       



	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("用户登录成功");
		//获取到用户会话的session对象
		HttpSession session = request.getSession();
		//setAttribute设置session的属性名称和值
		session.setAttribute("name", "张达");
		//转到/session/index地址
		request.getRequestDispatcher("/session/index").forward(request, response);
		
	}

}
